#include "db_facade.h"
#include <iostream>


Db_facade::Db_facade()
{

     QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");

     db.setHostName("localhost");
     db.setDatabaseName("plokmc");
     db.setUserName("plokmc");
     bool ok = db.open();

     if (ok) {
        QSqlQuery query;
       std::cout << "query ok:" << query.exec("SELECT * FROM plk_album") << std::endl;
        std::cout << query.lastError().text().toStdString();
        while (query.next()) {
         QString name = query.value(0).toString();
         int salary = query.value(1).toInt();
         std::cout << name.toStdString() << " :" << salary;
        }
     }
     std::cout << "db ok:" << ok << std::endl;
}


